#include<stdio.h>
#include<stdlib.h>

int HalfSearch(int a[], int low, int high, int key)
{
	int mid;
	while (low <= high)
	{
		mid = (low + high) / 2;
		if (a[mid] == key) return mid;
		else if (a[mid] < key) low = mid + 1;
		else high = mid - 1;
	}
	return -1;
}

int main(void)
{
	int a[10] = { 18, 28, 38, 68, 76, 78, 89, 92, 150, 190 };
	int n;
	int key;
	printf("enter data to key:\n");
	scanf_s("%5d", &key);
	n = HalfSearch(a, 0, 9, key);
	if (n == -1) printf("not found!\n");//??
	else  printf("key=%d", a[n]);
	return 0;
}
